<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <script>

        function* fib(max) {
            var
                t,
                a = 0,
                b = 1,
                n = 0;
            while (n < max) {
                yield a;
                [a, b] = [b, a + b];
                n ++;
            }
            return;
        }

        console.log(fib(5));
    </script>
</body>
</html>